package com.wwinsoft.framework.dao.system;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.wwinsoft.framework.entity.system.SystemSetting;
import com.wwinsoft.modules.orm.hibernate.HibernateDao;

/**
 * @author: Tim.Chen
 * @since: 1.0
 */
@Repository
@SuppressWarnings("unchecked")
public class SystemSettingDao extends HibernateDao<SystemSetting, Long> {

    public String getCachedValue(String key) {
        Criteria criteria = this.createCriteria();
        criteria.add(Restrictions.eq("key", key));
        criteria.setCacheable(true);
        List<SystemSetting> list = criteria.list();
        if (list.size() > 0) {
            return list.get(0).getValue();
        } else {
            return null;
        }
    }
}
